import {
	myRequest
} from '../http.js'
import qs from 'qs'
// 获取首页轮播图
export function getBanner() {
	return myRequest({
		url: '/index/carousel?lang=cn',
		method: 'get',
	})
}
//获取人气商品
export function gethotgoods() {
	return myRequest({
		url: '/index/hot?lang=cn',
		method: 'get'
	})
}
//商品分类
export function getclassify() {
	return myRequest({
		url: '/index/goodslist?lang=cn',
		method: 'get'
	})
}
//商品详情
export function goodDetails(goods_id, user_id) {
	return myRequest({
		url: `/detail/detail?lang=cn&goods_id=${goods_id}&user_id=${user_id?user_id:'null'}`,
		method: 'get',
	})
}
// 相关推荐
export function recommend(id) {
	return myRequest({
		url: '/goodslist/recommend?lang=cn',
		data: {
			id: id
		},
		method: 'get'
	})
}

//筛选
// 获取子类列表
export function getCate(searchdata) {
	return myRequest({
		url: `/index/cate?lang=cn&id=${searchdata.id}&search=${searchdata.search}&brand_id=${searchdata.brand}&priority=${searchdata.priority}`,
		method: 'get'
	})
}
// 获取品牌
export function getBrand(searchdata) {
	return myRequest({
		url: `/goodslist/brand?lang=cn&id=${searchdata.id}&search=${searchdata.search}&brand_id=${searchdata.brand}&priority=${searchdata.priority}`,
		method: 'get'
	})
}

//搜索
export function getSearch(searchdata) {
	return myRequest({
		url: "/search/search",
		method: 'post',
		data: qs.stringify(searchdata)
	})
}
//搜索推荐
export function searchlist(keyword){
	return myRequest({
		url: '/search/sear',
		method: 'post',
		data:{
			lang: 'cn',
			search: keyword
		}
	})
}
//获取分类列表
export function getclassifylist() {
	return myRequest({
		url: `/index/category?lang=cn`,
		method: 'get'
	})
}
